package com.daiziru.wuyanmall.service.impl;

import com.daiziru.wuyanmall.dao.CategoryMapper;
import com.daiziru.wuyanmall.entity.CategoryVO;
import com.daiziru.wuyanmall.service.CategoryService;
import com.daiziru.wuyanmall.vo.ResultStatus;
import com.daiziru.wuyanmall.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;
    @Override
    public ResultVO listCategories() {
        List<CategoryVO> categoryVOS = categoryMapper.selectAllCategories();
        ResultVO resultVO = new ResultVO(ResultStatus.OK, "success", categoryVOS);
        return resultVO;
    }

    @Override
    public ResultVO selectFirstLevelCategories() {
        List<CategoryVO> categoryVOS = categoryMapper.selectFirstLevelCategories();
        ResultVO resultVO = new ResultVO(ResultStatus.OK, "success", categoryVOS);
        return resultVO;
    }
}
